using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using Mpi.Common.Graphic;
using Xeml.Document;

namespace Xid.Controls
{
    public partial class OlC_BaseCtrl : UserControl
    {

       

        private Color col1 = Color.DarkRed;
        private Color col2 = Color.OrangeRed;
        private float angle = 220f;
        private Color borderColor = Color.Black;

        public Color BorderColor
        {
            get { return borderColor; }
            set { borderColor = value; Invalidate(); }
        }

        public float Angle
        {
            get { return angle; }
            set { angle = value; Invalidate(); }
        }


        public Color Color2
        {
            get { return col2; }
            set { col2 = value; Invalidate(); }
        }


        public Color Color1
        {
            get { return col1; }
            set { col1 = value; Invalidate(); }
        }

        public Point MiddleRight
        {
            get { return new Point(this.Right, this.Top + ((this.Bottom - this.Top) / 2)); }

        }

        public Point MiddleLeft
        {
            get { return new Point(this.Left, this.Top + ((this.Bottom - this.Top) / 2)); }

        }

	

        public OlC_BaseCtrl()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.BackColor = Color.Transparent;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            RectangleF rect = new RectangleF(0, 0, (this.Width - 1), (this.Height - 1));
            using (Brush b = new LinearGradientBrush(rect, col1, col2, angle))
            {
                using (Pen p = new Pen(borderColor, 2f))
                {

                    g.FillPath(b, GraphicEffect.RoundRect(rect, 4f));
                    g.DrawPath(p, GraphicEffect.RoundRect(rect, 4f));
                }
            }
            base.OnPaint(e);
        }
    }
}
